import Vue from "vue";

//==============================getData=================================
const getData = {
    // 是否为空判断
    getAllData: function () {
        var data = [
            {
                id: "all",
                label: "全部设备",
                children: [
                    { id: "spjk", label: "视频监控", children: [] },
                    { id: "mjgl", label: "门禁管理", children: [] },
                    { id: "gggb", label: "公共广播", children: [] },
                    { id: "xxfb", label: "信息发布", children: [] },
                    { id: "ntxt", label: "楼控系统", children: [] },
                    { id: "xfxt", label: "消防系统", children: [] },
                    { id: "tcxt", label: "停车系统", children: [] },
                    { id: "jjqz", label: "紧急求助", children: [] },
                    { id: "dzxg", label: "电子巡更", children: [] },
                ],
            },
        ]
        var vedioArr = [
            { id: "视频1L", label: "1 楼", children: [] },
            { id: "视频2L", label: "2 楼", children: [] },
            { id: "视频3L", label: "3 楼", children: [] },
            { id: "视频4L", label: "4 楼", children: [] },
            { id: "视频5L", label: "5 楼", children: [] },
        ];
        var accessArr = [
            { id: "门禁1L", label: "1 楼", children: [] },
            { id: "门禁2L", label: "2 楼", children: [] },
            { id: "门禁3L", label: "3 楼", children: [] },
            { id: "门禁4L", label: "4 楼", children: [] },
            { id: "门禁5L", label: "5 楼", children: [] },
        ];
        var infoArr = [
            { id: "信息发布1L", label: "1 楼", children: [] },
            { id: "信息发布2L", label: "2 楼", children: [] },
            { id: "信息发布3L", label: "3 楼", children: [] },
            { id: "信息发布4L", label: "4 楼", children: [] },
            { id: "信息发布5L", label: "5 楼", children: [] },
        ];
        var airArr = [
            { id: "楼控系统1L", label: "1 楼", children: [] },
            { id: "楼控系统2L", label: "2 楼", children: [] },
            { id: "楼控系统3L", label: "3 楼", children: [] },
            { id: "楼控系统4L", label: "4 楼", children: [] },
            { id: "楼控系统5L", label: "5 楼", children: [] },
        ];
        var fireArr = [
            { id: "消防系统1L", label: "1 楼", children: [] },
            { id: "消防系统2L", label: "2 楼", children: [] },
            { id: "消防系统3L", label: "3 楼", children: [] },
            { id: "消防系统4L", label: "4 楼", children: [] },
            { id: "消防系统5L", label: "5 楼", children: [] },
        ];
        var broadArr = [
            { id: "公共广播1L", label: "1 楼", children: [] },
            { id: "公共广播2L", label: "2 楼", children: [] },
            { id: "公共广播3L", label: "3 楼", children: [] },
            { id: "公共广播4L", label: "4 楼", children: [] },
            { id: "公共广播5L", label: "5 楼", children: [] },
        ];
        window.Sgworld.execute("grapi", "GetALL", {}, (e) => {
            // 设备所在楼层
            var LC = e.args.name.substring(0, 2);
            // 设备的名称
            var MX = e.args.name.substring(3);
            // 设备所在的位置
            // var tposition = { ...e.args.location, ...e.CameraTransform.Rotation };
            var tposition = {};
            tposition.x = e.args.location.x;
            tposition.y = e.args.location.y;
            tposition.z = e.args.location.z;
            tposition.roll = e.CameraTransform.Rotation.roll;
            tposition.pitch = e.CameraTransform.Rotation.pitch;
            tposition.yaw = e.CameraTransform.Rotation.yaw;
            var item = {
                id: MX,
                label: MX,
                floorId: LC,
                buildName: "展示中心大楼",
                position: tposition,
            };
            if (e.args.name.indexOf("摄像头") != -1) {
                LC == "1F" && vedioArr[0].children.push(item);
                LC == "2F" && vedioArr[1].children.push(item);
                LC == "3F" && vedioArr[2].children.push(item);
                LC == "4F" && vedioArr[3].children.push(item);
                LC == "5F" && vedioArr[4].children.push(item);
                data[0].children[0].children = vedioArr;
            } else if (e.args.name.indexOf("门禁") != -1) {
                LC == "1F" && accessArr[0].children.push(item);
                LC == "2F" && accessArr[1].children.push(item);
                LC == "3F" && accessArr[2].children.push(item);
                LC == "4F" && accessArr[3].children.push(item);
                LC == "5F" && accessArr[4].children.push(item);
                data[0].children[1].children = accessArr;
            } else if (e.args.name.indexOf("信息发布") != -1) {
                LC == "1F" && infoArr[0].children.push(item);
                LC == "2F" && infoArr[1].children.push(item);
                LC == "3F" && infoArr[2].children.push(item);
                LC == "4F" && infoArr[3].children.push(item);
                LC == "5F" && infoArr[4].children.push(item);
                data[0].children[3].children = infoArr;
            } else if (
                e.args.name.indexOf("空调") != -1 ||
                e.args.name.indexOf("风机") != -1
            ) {
                LC == "1F" && airArr[0].children.push(item);
                LC == "2F" && airArr[1].children.push(item);
                LC == "3F" && airArr[2].children.push(item);
                LC == "4F" && airArr[3].children.push(item);
                LC == "5F" && airArr[4].children.push(item);
                data[0].children[4].children = airArr;
            } else if (
                e.args.name.indexOf("消防") != -1 ||
                e.args.name.indexOf("报警器") != -1 ||
                e.args.name.indexOf("灭火装置") != -1
            ) {
                LC == "1F" && fireArr[0].children.push(item);
                LC == "2F" && fireArr[1].children.push(item);
                LC == "3F" && fireArr[2].children.push(item);
                LC == "4F" && fireArr[3].children.push(item);
                LC == "5F" && fireArr[4].children.push(item);
                data[0].children[5].children = fireArr;
            } else if (e.args.name.indexOf("喇叭") != -1) {
                LC == "1F" && broadArr[0].children.push(item);
                LC == "2F" && broadArr[1].children.push(item);
                LC == "3F" && broadArr[2].children.push(item);
                LC == "4F" && broadArr[3].children.push(item);
                LC == "5F" && broadArr[4].children.push(item);
                data[0].children[2].children = broadArr;
            }
        });
        return data
    }
};
Vue.prototype.getData = getData.getAllData;
//==============================getData=================================


export default {};